package behaviors;

import model.Assets;
import model.Entity;

import org.jbox2d.dynamics.Body;
import org.jbox2d.dynamics.contacts.ContactPoint;
import org.jbox2d.dynamics.contacts.ContactResult;

public class Health extends Behavior {
	private long t = 0;
	public Entity shapeData1, shapeData2;

	@Override
	public void onCollide(ContactPoint arg0) {

		shapeData1 = ((Entity) arg0.shape1.getBody().getUserData());
		shapeData2 = ((Entity) arg0.shape2.getBody().getUserData());

		if (shapeData1.name.equals("player")) {
			shapeData1.health += 100;
			shapeData2.recycle = true;
			Assets.getInstance().getSound("assets/sfx/enchant.ogg").play();
		} else if (shapeData2.name.equals("player")) {
			shapeData2.health += 100;
			shapeData1.recycle = true;
			Assets.getInstance().getSound("assets/sfx/enchant.ogg").play();
		}
	}

	@Override
	public void onPersist(ContactPoint arg0) {
	}

	@Override
	public void onRemove(ContactPoint arg0) {
	}

	@Override
	public void onResult(ContactResult arg0) {
	}

	@Override
	public void update(Body b) {
		super.update(b);
	}

	@Override
	public Behavior clone() {
		Health obj = new Health();
		obj.t = this.t;
		return obj;
	}

	@Override
	public void init() {
	}
}
